using System.ComponentModel.DataAnnotations.Schema;
using System.Data.Entity.ModelConfiguration;

namespace Turquoise.EntityGenerator.Models.Mapping
{
    public class KeywordLanguageLineMap : EntityTypeConfiguration<KeywordLanguageLine>
    {
        public KeywordLanguageLineMap()
        {
            // Primary Key
            this.HasKey(t => t.Id);

            // Properties
            this.Property(t => t.KeywordName)
                .IsRequired()
                .HasMaxLength(400);

            this.Property(t => t.KeywordDescription)
                .HasMaxLength(500);

            // Table & Column Mappings
            this.ToTable("KeywordLanguageLine");
            this.Property(t => t.Id).HasColumnName("Id");
            this.Property(t => t.KeywordId).HasColumnName("KeywordId");
            this.Property(t => t.LanguageId).HasColumnName("LanguageId");
            this.Property(t => t.KeywordName).HasColumnName("KeywordName");
            this.Property(t => t.KeywordDescription).HasColumnName("KeywordDescription");
            this.Property(t => t.CreateDate).HasColumnName("CreateDate");
            this.Property(t => t.CreatedBy).HasColumnName("CreatedBy");
            this.Property(t => t.UpdateDate).HasColumnName("UpdateDate");
            this.Property(t => t.UpdatedBy).HasColumnName("UpdatedBy");
            this.Property(t => t.DisplayOrder).HasColumnName("DisplayOrder");
            this.Property(t => t.IsApproved).HasColumnName("IsApproved");

            // Relationships
            this.HasRequired(t => t.Keyword)
                .WithMany(t => t.KeywordLanguageLines)
                .HasForeignKey(d => d.KeywordId);
            this.HasRequired(t => t.User)
                .WithMany(t => t.KeywordLanguageLines)
                .HasForeignKey(d => d.CreatedBy);
            this.HasRequired(t => t.Language)
                .WithMany(t => t.KeywordLanguageLines)
                .HasForeignKey(d => d.LanguageId);
            this.HasRequired(t => t.User1)
                .WithMany(t => t.KeywordLanguageLines1)
                .HasForeignKey(d => d.UpdatedBy);

        }
    }
}
